home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 June / PersonalComputerWorld-June2009-CoverdiscCD.iso / Software / Freeware / Firebug 1.3.3 / firebug-1.3.3-fx.xpi / content / firebug / reps.js < prev    next >
Encoding:
JavaScript  |  2009-02-19  |  42.8 KB  |  1,581 lines

  1. /* See license.txt for terms of usage */
  2.  
  3. var FirebugReps = FBL.ns(function() { with (FBL) {
  4.  
  5. // ************************************************************************************************
  6. // Constants
  7.  
  8. const Cc = Components.classes;
  9. const Ci = Components.interfaces;
  10. const jsdIStackFrame = Ci.jsdIStackFrame;
  11. const jsdIScript = Ci.jsdIScript;
  12.  
  13. const fbs = Cc["@joehewitt.com/firebug;1"].getService().wrappedJSObject;
  14.  
  15. // ************************************************************************************************
  16. // Common Tags
  17.  
  18. var OBJECTBOX = this.OBJECTBOX =
  19.     SPAN({class: "objectBox objectBox-$className"});
  20.  
  21. var OBJECTBLOCK = this.OBJECTBLOCK =
  22.     DIV({class: "objectBox objectBox-$className"});
  23.  
  24. var OBJECTLINK = this.OBJECTLINK =
  25.     A({
  26.         class: "objectLink objectLink-$className",
  27.         _repObject: "$object"
  28.     });
  29.  
  30. // ************************************************************************************************
  31.  
  32. this.Undefined = domplate(Firebug.Rep,
  33. {
  34.     tag: OBJECTBOX("undefined"),
  35.  
  36.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  37.  
  38.     className: "undefined",
  39.  
  40.     supportsObject: function(object, type)
  41.     {
  42.         return type == "undefined";
  43.     }
  44. });
  45.  
  46. // ************************************************************************************************
  47.  
  48. this.Null = domplate(Firebug.Rep,
  49. {
  50.     tag: OBJECTBOX("null"),
  51.  
  52.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  53.  
  54.     className: "null",
  55.  
  56.     supportsObject: function(object, type)
  57.     {
  58.         return object == null;
  59.     }
  60. });
  61.  
  62. // ************************************************************************************************
  63.  
  64. this.Nada = domplate(Firebug.Rep,
  65. {
  66.     tag: SPAN(""),
  67.  
  68.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  69.  
  70.     className: "nada"
  71. });
  72.  
  73. // ************************************************************************************************
  74.  
  75. this.Number = domplate(Firebug.Rep,
  76. {
  77.     tag: OBJECTBOX("$object"),
  78.  
  79.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  80.  
  81.     className: "number",
  82.  
  83.     supportsObject: function(object, type)
  84.     {
  85.         return type == "boolean" || type == "number";
  86.     }
  87. });
  88.  
  89. // ************************************************************************************************
  90.  
  91. this.String = domplate(Firebug.Rep,
  92. {
  93.     tag: OBJECTBOX(""$object""),
  94.  
  95.     shortTag: OBJECTBOX(""$object|cropString""),
  96.  
  97.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  98.  
  99.     className: "string",
  100.  
  101.     supportsObject: function(object, type)
  102.     {
  103.         return type == "string";
  104.     }
  105. });
  106.  
  107. // ************************************************************************************************
  108.  
  109. this.Text = domplate(Firebug.Rep,
  110. {
  111.     tag: OBJECTBOX("$object"),
  112.  
  113.     shortTag: OBJECTBOX("$object|cropString"),
  114.  
  115.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  116.  
  117.     className: "text"
  118. });
  119.  
  120. // ************************************************************************************************
  121.  
  122. this.Caption = domplate(Firebug.Rep,
  123. {
  124.     tag: SPAN({class: "caption"}, "$object")
  125. });
  126.  
  127. // ************************************************************************************************
  128.  
  129. this.Warning = domplate(Firebug.Rep,
  130. {
  131.     tag: DIV({class: "warning"}, "$object|STR")
  132. });
  133.  
  134. // ************************************************************************************************
  135.  
  136. this.Func = domplate(Firebug.Rep,
  137. {
  138.     tag:
  139.         OBJECTLINK("$object|summarizeFunction"),
  140.  
  141.     summarizeFunction: function(fn)
  142.     {
  143.         var fnRegex = /function ([^(]+\([^)]*\)) \{/;
  144.         var fnText = safeToString(fn);
  145.  
  146.         var m = fnRegex.exec(fnText);
  147.         return m ? m[1] : "function()";
  148.     },
  149.  
  150.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  151.  
  152.     copySource: function(fn)
  153.     {
  154.         copyToClipboard(safeToString(fn));
  155.     },
  156.  
  157.     monitor: function(fn, script, monitored)
  158.     {
  159.         if (monitored)
  160.             Firebug.Debugger.untraceFunction(fn, script, "monitor");
  161.         else
  162.             Firebug.Debugger.traceFunction(fn, script, "monitor");
  163.     },
  164.  
  165.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  166.  
  167.     className: "function",
  168.  
  169.     supportsObject: function(object, type)
  170.     {
  171.         return type == "function";
  172.     },
  173.  
  174.     inspectObject: function(fn, context)
  175.     {
  176.         var sourceLink = findSourceForFunction(fn, context);
  177.         if (sourceLink)
  178.             context.chrome.select(sourceLink);
  179.     },
  180.  
  181.     getTooltip: function(fn, context)
  182.     {
  183.         var script = findScriptForFunctionInContext(context, fn);
  184.         if (script)
  185.             return $STRF("Line", [normalizeURL(script.fileName), script.baseLineNumber]);
  186.         else
  187.             if (fn.toString)
  188.                 return fn.toString();
  189.     },
  190.  
  191.     getTitle: function(fn, context)
  192.     {
  193.         var name = fn.name ? fn.name : "function";
  194.         return name + "()";
  195.     },
  196.  
  197.     getContextMenuItems: function(fn, target, context, script)
  198.     {
  199.         if (!script)
  200.             script = findScriptForFunctionInContext(context, fn);
  201.         if (!script)
  202.             return;
  203.  
  204.         var scriptInfo = getSourceFileAndLineByScript(context, script);
  205.         var monitored = scriptInfo ? fbs.isMonitored(scriptInfo.sourceFile.href, scriptInfo.lineNo) : false;
  206.  
  207.         var name = script ? getFunctionName(script, context) : fn.name;
  208.         return [
  209.             {label: "CopySource", command: bindFixed(this.copySource, this, fn) },
  210.             "-",
  211.             {label: $STRF("ShowCallsInConsole", [name]), nol10n: true,
  212.              type: "checkbox", checked: monitored,
  213.              command: bindFixed(this.monitor, this, fn, script, monitored) }
  214.         ];
  215.     }
  216. });
  217.  
  218. // ************************************************************************************************
  219.  
  220. this.jsdScript = domplate(Firebug.Rep,
  221. {
  222.     copySource: function(script)
  223.     {
  224.         var fn = script.functionObject.getWrappedValue();
  225.         return FirebugReps.Func.copySource(fn);
  226.     },
  227.  
  228.     monitor: function(fn, script, monitored)
  229.     {
  230.         fn = script.functionObject.getWrappedValue();
  231.         return FirebugReps.Func.monitor(fn, script, monitored);
  232.     },
  233.  
  234.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  235.  
  236.     className: "jsdScript",
  237.     inspectable: false,
  238.  
  239.     supportsObject: function(object, type)
  240.     {
  241.         return object instanceof jsdIScript;
  242.     },
  243.  
  244.     inspectObject: function(script, context)
  245.     {
  246.         var sourceLink = getSourceLinkForScript(script, context);
  247.         if (sourceLink)
  248.             context.chrome.select(sourceLink);
  249.     },
  250.  
  251.     getRealObject: function(script, context)
  252.     {
  253.         return script;
  254.     },
  255.  
  256.     getTooltip: function(script)
  257.     {
  258.         return $STRF("jsdIScript", [script.tag]);
  259.     },
  260.  
  261.     getTitle: function(script, context)
  262.     {
  263.         var fn = script.functionObject.getWrappedValue();
  264.         return FirebugReps.Func.getTitle(fn, context);
  265.     },
  266.  
  267.     getContextMenuItems: function(script, target, context)
  268.     {
  269.         var fn = script.functionObject.getWrappedValue();
  270.  
  271.         var scriptInfo = getSourceFileAndLineByScript(context, script);
  272.            var monitored = scriptInfo ? fbs.isMonitored(scriptInfo.sourceFile.href, scriptInfo.lineNo) : false;
  273.  
  274.         var name = getFunctionName(script, context);
  275.  
  276.         return [
  277.             {label: "CopySource", command: bindFixed(this.copySource, this, script) },
  278.             "-",
  279.             {label: $STRF("ShowCallsInConsole", [name]), nol10n: true,
  280.              type: "checkbox", checked: monitored,
  281.              command: bindFixed(this.monitor, this, fn, script, monitored) }
  282.         ];
  283.     }
  284. });
  285.  
  286. //************************************************************************************************
  287.  
  288. this.Obj = domplate(Firebug.Rep,
  289. {
  290.     tag:
  291.         OBJECTLINK(
  292.             SPAN({class: "objectTitle"}, "$object|getTitle"),
  293.             FOR("prop", "$object|propIterator",
  294.                 " $prop.name=",
  295.                 SPAN({class: "objectPropValue"}, "$prop.value|cropString")
  296.             )
  297.         ),
  298.  
  299.     propIterator: function (object)
  300.     {
  301.         if (!object)
  302.             return [];
  303.  
  304.         var props = [];
  305.         var len = 0;
  306.  
  307.         try
  308.         {
  309.             for (var name in object)
  310.             {
  311.                 var val;
  312.                 try
  313.                 {
  314.                     val = object[name];
  315.                 }
  316.                 catch (exc)
  317.                 {
  318.                     continue;
  319.                 }
  320.  
  321.                 var t = typeof(val);
  322.                 if (t == "boolean" || t == "number" || (t == "string" && val)
  323.                     || (t == "object" && val && val.toString))
  324.                 {
  325.                     var title = (t == "object")
  326.                         ? Firebug.getRep(val).getTitle(val)
  327.                         : val+"";
  328.  
  329.                     len += name.length + title.length + 1;
  330.                     if (len < 50)
  331.                         props.push({name: name, value: title});
  332.                     else
  333.                         break;
  334.                 }
  335.             }
  336.         }
  337.         catch (exc)
  338.         {
  339.             // Sometimes we get exceptions when trying to read from certain objects, like
  340.             // StorageList, but don't let that gum up the works
  341.             // XXXjjb also History.previous fails because object is a web-page object which does not have
  342.             // permission to read the history
  343.         }
  344.  
  345.         return props;
  346.     },
  347.  
  348.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  349.  
  350.     className: "object",
  351.  
  352.     supportsObject: function(object, type)
  353.     {
  354.         return true;
  355.     }
  356. });
  357.  
  358.  
  359. // ************************************************************************************************
  360.  
  361. this.Arr = domplate(Firebug.Rep,
  362. {
  363.     tag:
  364.         OBJECTBOX({_repObject: "$object"},
  365.             SPAN({class: "arrayLeftBracket"}, "["),
  366.             FOR("item", "$object|arrayIterator",
  367.                 TAG("$item.tag", {object: "$item.object"}),
  368.                 SPAN({class: "arrayComma"}, "$item.delim")
  369.             ),
  370.             SPAN({class: "arrayRightBracket"}, "]")
  371.         ),
  372.  
  373.     shortTag:
  374.         OBJECTBOX({_repObject: "$object"},
  375.             SPAN({class: "arrayLeftBracket"}, "["),
  376.             FOR("item", "$object|shortArrayIterator",
  377.                 TAG("$item.tag", {object: "$item.object"}),
  378.                 SPAN({class: "arrayComma"}, "$item.delim")
  379.             ),
  380.             FOR("prop", "$object|shortPropIterator",
  381.                     " $prop.name=",
  382.                     SPAN({class: "objectPropValue"}, "$prop.value|cropString")
  383.             ),
  384.             SPAN({class: "arrayRightBracket"}, "]")
  385.         ),
  386.  
  387.     arrayIterator: function(array)
  388.     {
  389.         var items = [];
  390.         for (var i = 0; i < array.length; ++i)
  391.         {
  392.             var value = array[i];
  393.             var rep = Firebug.getRep(value);
  394.             var tag = rep.shortTag ? rep.shortTag : rep.tag;
  395.             var delim = (i == array.length-1 ? "" : ", ");
  396.  
  397.             items.push({object: value, tag: tag, delim: delim});
  398.         }
  399.  
  400.         return items;
  401.     },
  402.  
  403.     shortArrayIterator: function(array)
  404.     {
  405.         var items = [];
  406.         for (var i = 0; i < array.length && i < 3; ++i)
  407.         {
  408.             var value = array[i];
  409.             var rep = Firebug.getRep(value);
  410.             var tag = rep.shortTag ? rep.shortTag : rep.tag;
  411.             var delim = (i == array.length-1 ? "" : ", ");
  412.  
  413.             items.push({object: value, tag: tag, delim: delim});
  414.         }
  415.  
  416.         if (array.length > 3)
  417.             items.push({object: (array.length-3) + " more...", tag: FirebugReps.Caption.tag, delim: ""});
  418.  
  419.         return items;
  420.     },
  421.  
  422.     shortPropIterator:    this.Obj.propIterator,
  423.     
  424.     getItemIndex: function(child)
  425.     {
  426.         var arrayIndex = 0;
  427.         for (child = child.previousSibling; child; child = child.previousSibling)
  428.         {
  429.             if (child.repObject)
  430.                 ++arrayIndex;
  431.         }
  432.         return arrayIndex;
  433.     },
  434.  
  435.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  436.  
  437.     className: "array",
  438.  
  439.     supportsObject: function(object)
  440.     {
  441.         if (this.isArray(object)) return true;
  442.  
  443.         // Don't use propertyIsEnumerable("length") as "arguments" array isn't real JS array,
  444.         // "arguments" have .length but do not respond to object property enumeration.
  445.         if ("length" in object && typeof(object.length) == "number")
  446.         {
  447.             for (name in object)
  448.                 return false;
  449.             return true;
  450.         }
  451.     },
  452.  
  453.     // http://code.google.com/p/fbug/issues/detail?id=874
  454.     // BEGIN Yahoo BSD Source (modified here)  YAHOO.lang.isArray, YUI 2.2.2 June 2007
  455.     isArray: function(obj) {
  456.         try {
  457.             if (!obj)
  458.                 return false;
  459.             else if (isFinite(obj.length) && typeof obj.splice === 'function')
  460.                 return true;
  461.             else if (obj instanceof HTMLCollection)
  462.                 return true;
  463.             else if (obj instanceof NodeList)
  464.                 return true;
  465.             else
  466.                 return false;
  467.         }
  468.         catch(exc)
  469.         {
  470.         }
  471.  
  472.         return false;
  473.     },
  474.     // END Yahoo BSD SOURCE See license below.
  475.  
  476.     getTitle: function(object, context)
  477.     {
  478.         return "[" + object.length + "]";
  479.     }
  480. });
  481.  
  482. // ************************************************************************************************
  483.  
  484. this.Property = domplate(Firebug.Rep,
  485. {
  486.     supportsObject: function(object)
  487.     {
  488.         return object instanceof Property;
  489.     },
  490.  
  491.     getRealObject: function(prop, context)
  492.     {
  493.         return prop.object[prop.name];
  494.     },
  495.  
  496.     getTitle: function(prop, context)
  497.     {
  498.         return prop.name;
  499.     }
  500. });
  501.  
  502. // ************************************************************************************************
  503.  
  504. this.NetFile = domplate(Firebug.Rep,
  505. {
  506.     supportsObject: function(object)
  507.     {
  508.         return object instanceof Firebug.NetFile;
  509.     },
  510.  
  511.     browseObject: function(file, context)
  512.     {
  513.         openNewTab(file.href);
  514.         return true;
  515.     },
  516.  
  517.     getRealObject: function(file, context)
  518.     {
  519.         return null;
  520.     }
  521. });
  522.  
  523. // ************************************************************************************************
  524.  
  525. this.Except = domplate(Firebug.Rep,
  526. {
  527.     tag:
  528.         OBJECTBOX({_repObject: "$object"}, "$object.message"),
  529.  
  530.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  531.  
  532.     className: "exception",
  533.  
  534.     supportsObject: function(object)
  535.     {
  536.         return object instanceof ErrorCopy;
  537.     }
  538. });
  539.  
  540.  
  541. // ************************************************************************************************
  542.  
  543. this.Element = domplate(Firebug.Rep,
  544. {
  545.     tag:
  546.         OBJECTLINK(
  547.             "<",
  548.             SPAN({class: "nodeTag"}, "$object.localName|toLowerCase"),
  549.             FOR("attr", "$object|attrIterator",
  550.                 " $attr.localName="", SPAN({class: "nodeValue"}, "$attr.nodeValue"), """
  551.             ),
  552.             ">"
  553.          ),
  554.  
  555.     shortTag:
  556.         OBJECTLINK(
  557.             SPAN({class: "$object|getVisible"},
  558.                 SPAN({class: "selectorTag"}, "$object|getSelectorTag"),
  559.                 SPAN({class: "selectorId"}, "$object|getSelectorId"),
  560.                 SPAN({class: "selectorClass"}, "$object|getSelectorClass"),
  561.                 SPAN({class: "selectorValue"}, "$object|getValue")
  562.             )
  563.          ),
  564.  
  565.      getVisible: function(elt)
  566.      {
  567.          return isVisible(elt) ? "" : "selectorHidden";
  568.      },
  569.  
  570.      getSelectorTag: function(elt)
  571.      {
  572.          return elt.localName.toLowerCase();
  573.      },
  574.  
  575.      getSelectorId: function(elt)
  576.      {
  577.          return elt.id ? ("#" + elt.id) : "";
  578.      },
  579.  
  580.      getSelectorClass: function(elt)
  581.      {
  582.          return elt.getAttribute("class")
  583.              ? ("." + elt.getAttribute("class").split(" ")[0])
  584.              : "";
  585.      },
  586.  
  587.      getValue: function(elt)
  588.      {
  589.          var value;
  590.          if (elt instanceof HTMLImageElement)
  591.             value = getFileName(elt.src);
  592.         else if (elt instanceof HTMLAnchorElement)
  593.             value = getFileName(elt.href);
  594.         else if (elt instanceof HTMLInputElement)
  595.             value = elt.value;
  596.         else if (elt instanceof HTMLFormElement)
  597.             value = getFileName(elt.action);
  598.         else if (elt instanceof HTMLScriptElement)
  599.             value = getFileName(elt.src);
  600.  
  601.         return value ? " " + cropString(value, 20) : "";
  602.      },
  603.  
  604.      attrIterator: function(elt)
  605.      {
  606.          var attrs = [];
  607.          var idAttr, classAttr;
  608.          if (elt.attributes)
  609.          {
  610.              for (var i = 0; i < elt.attributes.length; ++i)
  611.              {
  612.                  var attr = elt.attributes[i];
  613.                  if (attr.localName.indexOf("firebug-") != -1)
  614.                     continue;
  615.                  else if (attr.localName == "id")
  616.                      idAttr = attr;
  617.                 else if (attr.localName == "class")
  618.                     classAttr = attr;
  619.                  else
  620.                      attrs.push(attr);
  621.              }
  622.          }
  623.          if (classAttr)
  624.             attrs.splice(0, 0, classAttr);
  625.         if (idAttr)
  626.            attrs.splice(0, 0, idAttr);
  627.          return attrs;
  628.      },
  629.  
  630.      shortAttrIterator: function(elt)
  631.      {
  632.          var attrs = [];
  633.          if (elt.attributes)
  634.          {
  635.              for (var i = 0; i < elt.attributes.length; ++i)
  636.              {
  637.                  var attr = elt.attributes[i];
  638.                  if (attr.localName == "id" || attr.localName == "class")
  639.                      attrs.push(attr);
  640.              }
  641.          }
  642.  
  643.          return attrs;
  644.      },
  645.  
  646.      getHidden: function(elt)
  647.      {
  648.          return isVisible(elt) ? "" : "nodeHidden";
  649.      },
  650.  
  651.      getXPath: function(elt)
  652.      {
  653.          return getElementTreeXPath(elt);
  654.      },
  655.  
  656.      getNodeText: function(element)
  657.      {
  658.          var text = element.textContent;
  659.          if (Firebug.showFullTextNodes)
  660.             return text;
  661.         else
  662.             return cropString(text, 50);
  663.      },
  664.  
  665.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  666.  
  667.     copyHTML: function(elt)
  668.     {
  669.         var html = getElementXML(elt);
  670.         copyToClipboard(html);
  671.     },
  672.  
  673.     copyInnerHTML: function(elt)
  674.     {
  675.         copyToClipboard(elt.innerHTML);
  676.     },
  677.  
  678.     copyXPath: function(elt)
  679.     {
  680.         var xpath = getElementXPath(elt);
  681.         copyToClipboard(xpath);
  682.     },
  683.  
  684.     persistor: function(context, xpath)
  685.     {
  686.         var elts = xpath
  687.             ? getElementsByXPath(context.window.document, xpath)
  688.             : null;
  689.  
  690.         return elts && elts.length ? elts[0] : null;
  691.     },
  692.  
  693.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  694.  
  695.     className: "element",
  696.  
  697.     supportsObject: function(object)
  698.     {
  699.         return object instanceof Element;
  700.     },
  701.  
  702.     browseObject: function(elt, context)
  703.     {
  704.         var tag = elt.localName.toLowerCase();
  705.         if (tag == "script")
  706.             openNewTab(elt.src);
  707.         else if (tag == "link")
  708.             openNewTab(elt.href);
  709.         else if (tag == "a")
  710.             openNewTab(elt.href);
  711.         else if (tag == "img")
  712.             openNewTab(elt.src);
  713.  
  714.         return true;
  715.     },
  716.  
  717.     persistObject: function(elt, context)
  718.     {
  719.         var xpath = getElementXPath(elt);
  720.  
  721.         return bind(this.persistor, top, xpath);
  722.     },
  723.  
  724.     getTitle: function(element, context)
  725.     {
  726.         return getElementCSSSelector(element);
  727.     },
  728.  
  729.     getTooltip: function(elt)
  730.     {
  731.         return this.getXPath(elt);
  732.     },
  733.  
  734.     getContextMenuItems: function(elt, target, context)
  735.     {
  736.         var monitored = areEventsMonitored(elt, null, context);
  737.  
  738.         return [
  739.             {label: "CopyHTML", command: bindFixed(this.copyHTML, this, elt) },
  740.             {label: "CopyInnerHTML", command: bindFixed(this.copyInnerHTML, this, elt) },
  741.             {label: "CopyXPath", command: bindFixed(this.copyXPath, this, elt) },
  742.             "-",
  743.             {label: "ShowEventsInConsole", type: "checkbox", checked: monitored,
  744.              command: bindFixed(toggleMonitorEvents, FBL, elt, null, monitored, context) },
  745.             "-",
  746.             {label: "ScrollIntoView", command: bindFixed(elt.scrollIntoView, elt) }
  747.         ];
  748.     }
  749. });
  750.  
  751. // ************************************************************************************************
  752.  
  753. this.TextNode = domplate(Firebug.Rep,
  754. {
  755.     tag:
  756.         OBJECTLINK(""$object.nodeValue|cropString""),
  757.  
  758.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  759.  
  760.     className: "textNode",
  761.  
  762.     supportsObject: function(object)
  763.     {
  764.         return object instanceof Text;
  765.     }
  766. });
  767.  
  768. // ************************************************************************************************
  769.  
  770. this.Document = domplate(Firebug.Rep,
  771. {
  772.     tag:
  773.         OBJECTLINK("Document ", SPAN({class: "objectPropValue"}, "$object|getLocation")),
  774.  
  775.     getLocation: function(doc)
  776.     {
  777.         return doc.location ? getFileName(doc.location.href) : "";
  778.     },
  779.  
  780.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  781.  
  782.     className: "object",
  783.  
  784.     supportsObject: function(object)
  785.     {
  786.         return object instanceof Document || object instanceof XMLDocument;
  787.     },
  788.  
  789.     browseObject: function(doc, context)
  790.     {
  791.         openNewTab(doc.location.href);
  792.         return true;
  793.     },
  794.  
  795.     persistObject: function(doc, context)
  796.     {
  797.         return this.persistor;
  798.     },
  799.  
  800.     persistor: function(context)
  801.     {
  802.         return context.window.document;
  803.     },
  804.  
  805.     getTitle: function(win, context)
  806.     {
  807.         return "document";
  808.     },
  809.  
  810.     getTooltip: function(doc)
  811.     {
  812.         return doc.location.href;
  813.     }
  814. });
  815.  
  816. // ************************************************************************************************
  817.  
  818. this.StyleSheet = domplate(Firebug.Rep,
  819. {
  820.     tag:
  821.         OBJECTLINK("StyleSheet ", SPAN({class: "objectPropValue"}, "$object|getLocation")),
  822.  
  823.     getLocation: function(styleSheet)
  824.     {
  825.         return getFileName(styleSheet.href);
  826.     },
  827.  
  828.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  829.  
  830.     copyURL: function(styleSheet)
  831.     {
  832.         copyToClipboard(styleSheet.href);
  833.     },
  834.  
  835.     openInTab: function(styleSheet)
  836.     {
  837.         openNewTab(styleSheet.href);
  838.     },
  839.  
  840.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  841.  
  842.     className: "object",
  843.  
  844.     supportsObject: function(object)
  845.     {
  846.         return object instanceof CSSStyleSheet;
  847.     },
  848.  
  849.     browseObject: function(styleSheet, context)
  850.     {
  851.         openNewTab(styleSheet.href);
  852.         return true;
  853.     },
  854.  
  855.     persistObject: function(styleSheet, context)
  856.     {
  857.         return bind(this.persistor, top, styleSheet.href);
  858.     },
  859.  
  860.     getTooltip: function(styleSheet)
  861.     {
  862.         return styleSheet.href;
  863.     },
  864.  
  865.     getContextMenuItems: function(styleSheet, target, context)
  866.     {
  867.         return [
  868.             {label: "CopyLocation", command: bindFixed(this.copyURL, this, styleSheet) },
  869.             "-",
  870.             {label: "OpenInTab", command: bindFixed(this.openInTab, this, styleSheet) }
  871.         ];
  872.     },
  873.  
  874.     persistor: function(context, href)
  875.     {
  876.         return getStyleSheetByHref(href, context);
  877.     }
  878. });
  879.  
  880. // ************************************************************************************************
  881.  
  882. this.Window = domplate(Firebug.Rep,
  883. {
  884.     tag:
  885.         OBJECTLINK("Window ", SPAN({class: "objectPropValue"}, "$object|getLocation")),
  886.  
  887.     getLocation: function(win)
  888.     {
  889.         try
  890.         {
  891.             return (win && win.location && !win.closed) ? getFileName(win.location.href) : "";
  892.         }
  893.         catch (exc)
  894.         {
  895.         }
  896.     },
  897.  
  898.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  899.  
  900.     className: "object",
  901.  
  902.     supportsObject: function(object)
  903.     {
  904.         return object instanceof Window;
  905.     },
  906.  
  907.     browseObject: function(win, context)
  908.     {
  909.         openNewTab(win.location.href);
  910.         return true;
  911.     },
  912.  
  913.     persistObject: function(win, context)
  914.     {
  915.         return this.persistor;
  916.     },
  917.  
  918.     persistor: function(context)
  919.     {
  920.         return context.window;
  921.     },
  922.  
  923.     getTitle: function(win, context)
  924.     {
  925.         return "window";
  926.     },
  927.  
  928.     getTooltip: function(win)
  929.     {
  930.         return win.location.href;
  931.     }
  932. });
  933.  
  934. // ************************************************************************************************
  935.  
  936. this.Event = domplate(Firebug.Rep,
  937. {
  938.     tag: TAG("$copyEventTag", {object: "$object|copyEvent"}),
  939.  
  940.     copyEventTag:
  941.         OBJECTLINK("$object|summarizeEvent"),
  942.  
  943.     summarizeEvent: function(event)
  944.     {
  945.         var info = [event.type, ' '];
  946.  
  947.         var eventFamily = getEventFamily(event.type);
  948.         if (eventFamily == "mouse")
  949.             info.push("clientX=", event.clientX, ", clientY=", event.clientY);
  950.         else if (eventFamily == "key")
  951.             info.push("charCode=", event.charCode, ", keyCode=", event.keyCode);
  952.  
  953.         return info.join("");
  954.     },
  955.  
  956.     copyEvent: function(event)
  957.     {
  958.         return new EventCopy(event);
  959.     },
  960.  
  961.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  962.  
  963.     className: "object",
  964.  
  965.     supportsObject: function(object)
  966.     {
  967.         return object instanceof Event || object instanceof EventCopy;
  968.     },
  969.  
  970.     getTitle: function(event, context)
  971.     {
  972.         return "Event " + event.type;
  973.     }
  974. });
  975.  
  976. // ************************************************************************************************
  977.  
  978. this.SourceLink = domplate(Firebug.Rep,
  979. {
  980.     tag:
  981.         OBJECTLINK({$collapsed: "$object|hideSourceLink"}, "$object|getSourceLinkTitle"),
  982.  
  983.     hideSourceLink: function(sourceLink)
  984.     {
  985.         return sourceLink ? sourceLink.href.indexOf("XPCSafeJSObjectWrapper") != -1 : true;
  986.     },
  987.  
  988.     getSourceLinkTitle: function(sourceLink)
  989.     {
  990.         if (!sourceLink)
  991.             return "";
  992.  
  993.         var fileName = cropString(getFileName(sourceLink.href), 17);
  994.         fileName = decodeURIComponent(fileName);
  995.         return $STRF("Line", [fileName, sourceLink.line]);
  996.     },
  997.  
  998.     copyLink: function(sourceLink)
  999.     {
  1000.         copyToClipboard(sourceLink.href);
  1001.     },
  1002.  
  1003.     openInTab: function(sourceLink)
  1004.     {
  1005.         openNewTab(sourceLink.href);
  1006.     },
  1007.  
  1008.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  1009.  
  1010.     className: "sourceLink",
  1011.  
  1012.     supportsObject: function(object)
  1013.     {
  1014.         return object instanceof SourceLink;
  1015.     },
  1016.  
  1017.     getTooltip: function(sourceLink)
  1018.     {
  1019.         return decodeURI(sourceLink.href);
  1020.     },
  1021.  
  1022.     inspectObject: function(sourceLink, context)
  1023.     {
  1024.         if (sourceLink.type == "js")
  1025.         {
  1026.             var scriptFile = getScriptFileByHref(sourceLink.href, context);
  1027.             if (scriptFile)
  1028.                 return context.chrome.select(sourceLink);
  1029.         }
  1030.         else if (sourceLink.type == "css")
  1031.         {
  1032.             var stylesheet = getStyleSheetByHref(sourceLink.href, context);
  1033.             if (stylesheet)
  1034.             {
  1035.                 var ownerNode = stylesheet.ownerNode;
  1036.                 if (ownerNode)
  1037.                 {
  1038.                     context.chrome.select(sourceLink, "html");
  1039.                     return;
  1040.                 }
  1041.  
  1042.                 var panel = context.getPanel("stylesheet");
  1043.                 if (panel && panel.getRuleByLine(stylesheet, sourceLink.line))
  1044.                     return context.chrome.select(sourceLink);
  1045.             }
  1046.         }
  1047.  
  1048.         // Fallback is to just open the view-source window on the file
  1049.         viewSource(sourceLink.href, sourceLink.line);
  1050.     },
  1051.  
  1052.     browseObject: function(sourceLink, context)
  1053.     {
  1054.         openNewTab(sourceLink.href);
  1055.         return true;
  1056.     },
  1057.  
  1058.     getContextMenuItems: function(sourceLink, target, context)
  1059.     {
  1060.         return [
  1061.             {label: "CopyLocation", command: bindFixed(this.copyLink, this, sourceLink) },
  1062.             "-",
  1063.             {label: "OpenInTab", command: bindFixed(this.openInTab, this, sourceLink) }
  1064.         ];
  1065.     }
  1066. });
  1067.  
  1068. // ************************************************************************************************
  1069.  
  1070. this.SourceFile = domplate(this.SourceLink,
  1071. {
  1072.     tag:
  1073.         OBJECTLINK({$collapsed: "$object|hideSourceLink"}, "$object|getSourceLinkTitle"),
  1074.  
  1075.     persistor: function(context, href)
  1076.     {
  1077.         return getScriptFileByHref(href, context);
  1078.     },
  1079.  
  1080.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  1081.  
  1082.     className: "sourceFile",
  1083.  
  1084.     supportsObject: function(object)
  1085.     {
  1086.         return object instanceof SourceFile;
  1087.     },
  1088.  
  1089.     persistObject: function(sourceFile)
  1090.     {
  1091.         return bind(this.persistor, top, sourceFile.href);
  1092.     },
  1093.  
  1094.     browseObject: function(sourceLink, context)
  1095.     {
  1096.     },
  1097.  
  1098.     getTooltip: function(sourceFile)
  1099.     {
  1100.         return sourceFile.href;
  1101.     }
  1102. });
  1103.  
  1104. // ************************************************************************************************
  1105.  
  1106. this.StackFrame = domplate(Firebug.Rep,  // XXXjjb Since the repObject is fn the stack does not have correct line numbers
  1107. {
  1108.     tag:
  1109.         OBJECTBLOCK(
  1110.             A({class: "objectLink", _repObject: "$object"}, "$object|getCallName"),
  1111.             "(",
  1112.             FOR("arg", "$object|argIterator",
  1113.                 TAG("$arg.tag", {object: "$arg.value"}),
  1114.                 SPAN({class: "arrayComma"}, "$arg.delim")
  1115.             ),
  1116.             ")",
  1117.             SPAN({class: "objectLink-sourceLink objectLink"}, "$object|getSourceLinkTitle")
  1118.         ),
  1119.  
  1120.     getCallName: function(frame)
  1121.     {
  1122.         return getFunctionName(frame.script, frame.context);
  1123.     },
  1124.  
  1125.     getSourceLinkTitle: function(frame)
  1126.     {
  1127.         var fileName = cropString(getFileName(frame.href), 17);
  1128.         return $STRF("Line", [fileName, frame.lineNo]);
  1129.     },
  1130.  
  1131.     argIterator: function(frame)
  1132.     {
  1133.         if (!frame.args)
  1134.             return [];
  1135.  
  1136.         var items = [];
  1137.  
  1138.         for (var i = 0; i < frame.args.length; ++i)
  1139.         {
  1140.             var arg = frame.args[i];
  1141.  
  1142.             if (!arg)
  1143.                 break;
  1144.  
  1145.             var rep = Firebug.getRep(arg.value);
  1146.             var tag = rep.shortTag ? rep.shortTag : rep.tag;
  1147.  
  1148.             var delim = (i == frame.args.length-1 ? "" : ", ");
  1149.  
  1150.             items.push({name: arg.name, value: arg.value, tag: tag, delim: delim});
  1151.         }
  1152.  
  1153.         return items;
  1154.     },
  1155.  
  1156.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  1157.  
  1158.     className: "stackFrame",
  1159.  
  1160.     supportsObject: function(object)
  1161.     {
  1162.         return object instanceof StackFrame;
  1163.     },
  1164.  
  1165.     inspectObject: function(stackFrame, context)
  1166.     {
  1167.         var sourceLink = new SourceLink(stackFrame.href, stackFrame.lineNo, "js");
  1168.         context.chrome.select(sourceLink);
  1169.     },
  1170.  
  1171.     getTooltip: function(stackFrame, context)
  1172.     {
  1173.         return $STRF("Line", [stackFrame.href, stackFrame.lineNo]);
  1174.     },
  1175.  
  1176.  
  1177. });
  1178.  
  1179. // ************************************************************************************************
  1180.  
  1181. this.StackTrace = domplate(Firebug.Rep,
  1182. {
  1183.     tag:
  1184.         FOR("frame", "$object.frames",
  1185.             TAG(this.StackFrame.tag, {object: "$frame"})
  1186.         ),
  1187.  
  1188.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  1189.  
  1190.     className: "stackTrace",
  1191.  
  1192.     supportsObject: function(object)
  1193.     {
  1194.         return object instanceof StackTrace;
  1195.     }
  1196. });
  1197.  
  1198. // ************************************************************************************************
  1199.  
  1200. this.jsdStackFrame = domplate(Firebug.Rep,
  1201. {
  1202.     inspectable: false,
  1203.  
  1204.     supportsObject: function(object)
  1205.     {
  1206.         return (object instanceof jsdIStackFrame) && (object.isValid);
  1207.     },
  1208.  
  1209.     getTitle: function(frame, context)
  1210.     {
  1211.         if (!frame.isValid) return "(invalid frame)"; // XXXjjb avoid frame.script == null
  1212.         return getFunctionName(frame.script, context);
  1213.     },
  1214.  
  1215.     getTooltip: function(frame, context)
  1216.     {
  1217.         if (!frame.isValid) return "(invalid frame)";  // XXXjjb avoid frame.script == null
  1218.         var sourceInfo = FBL.getSourceFileAndLineByScript(context, frame.script, frame);
  1219.         if (sourceInfo)
  1220.             return $STRF("Line", [sourceInfo.sourceFile.href, sourceInfo.lineNo]);
  1221.     },
  1222.  
  1223.     getContextMenuItems: function(frame, target, context)
  1224.     {
  1225.         var fn = frame.script.functionObject.getWrappedValue();
  1226.         return FirebugReps.Func.getContextMenuItems(fn, target, context, frame.script);
  1227.     }
  1228. });
  1229.  
  1230. // ************************************************************************************************
  1231.  
  1232. this.ErrorMessage = domplate(Firebug.Rep,
  1233. {
  1234.     tag:
  1235.         OBJECTBOX({
  1236.                 $hasTwisty: "$object|hasStackTrace",
  1237.                 $hasBreakSwitch: "$object|hasBreakSwitch",
  1238.                 $breakForError: "$object|hasErrorBreak",
  1239.                 _repObject: "$object",
  1240.                 _stackTrace: "$object|getLastErrorStackTrace",
  1241.                 onclick: "$onToggleError"},
  1242.  
  1243.             DIV({class: "errorTitle"},
  1244.                 "$object.message|getMessage"
  1245.             ),
  1246.             DIV({class: "errorTrace"}),
  1247.             DIV({class: "errorSourceBox errorSource-$object|getSourceType"},
  1248.                 IMG({class: "errorBreak", src:"blank.gif", title: "Break on this error"}),
  1249.                 SPAN({class: "errorSource"}, "$object|getLine")
  1250.             ),
  1251.             TAG(this.SourceLink.tag, {object: "$object|getSourceLink"})
  1252.         ),
  1253.  
  1254.     getLastErrorStackTrace: function(error)
  1255.     {
  1256.         return error.trace;
  1257.     },
  1258.  
  1259.     hasStackTrace: function(error)
  1260.     {
  1261.         var fromCommandLine = error.href.indexOf("XPCSafeJSObjectWrapper") != -1;
  1262.         return !fromCommandLine && error.trace;
  1263.     },
  1264.  
  1265.     hasBreakSwitch: function(error)
  1266.     {
  1267.         return error.href && error.lineNo > 0;
  1268.     },
  1269.  
  1270.     hasErrorBreak: function(error)
  1271.     {
  1272.         return fbs.hasErrorBreakpoint(error.href, error.lineNo);
  1273.     },
  1274.  
  1275.     getMessage: function(message)
  1276.     {
  1277.         var re = /\[Exception... "(.*?)" nsresult:/;
  1278.         var m = re.exec(message);
  1279.         return m ? m[1] : message;
  1280.     },
  1281.  
  1282.     getLine: function(error)
  1283.     {
  1284.         if (error.category == "js")
  1285.         {
  1286.             if (error.source)
  1287.                 return cropString(error.source, 80);
  1288.             else if (error.href && error.href.indexOf("XPCSafeJSObjectWrapper") == -1)
  1289.                 return cropString(error.getSourceLine(), 80);
  1290.         }
  1291.     },
  1292.  
  1293.     getSourceLink: function(error)
  1294.     {
  1295.         var ext = error.category == "css" ? "css" : "js";
  1296.         return error.lineNo ? new SourceLink(error.href, error.lineNo, ext) : null;
  1297.     },
  1298.  
  1299.     getSourceType: function(error)
  1300.     {
  1301.         // Errors occurring inside of HTML event handlers look like "foo.html (line 1)"
  1302.         // so let's try to skip those
  1303.         if (error.source)
  1304.             return "syntax";
  1305.         else if (error.lineNo == 1 && getFileExtension(error.href) != "js")
  1306.             return "none";
  1307.         else if (error.category == "css")
  1308.             return "none";
  1309.         else if (!error.href || !error.lineNo)
  1310.             return "none";
  1311.         else
  1312.             return "exec";
  1313.     },
  1314.  
  1315.     onToggleError: function(event)
  1316.     {
  1317.         var target = event.currentTarget;
  1318.         if (hasClass(event.target, "errorBreak"))
  1319.         {
  1320.             this.breakOnThisError(target.repObject);
  1321.         }
  1322.         else if (hasClass(event.target, "errorSource"))
  1323.         {
  1324.             var panel = Firebug.getElementPanel(event.target);
  1325.             this.inspectObject(target.repObject, panel.context);
  1326.         }
  1327.         else if (hasClass(event.target, "errorTitle"))
  1328.         {
  1329.             var traceBox = target.childNodes[1];
  1330.             toggleClass(target, "opened");
  1331.  
  1332.             if (hasClass(target, "opened"))
  1333.             {
  1334.                 if (target.stackTrace)
  1335.                     FirebugReps.StackTrace.tag.append({object: target.stackTrace}, traceBox);
  1336.             }
  1337.             else
  1338.                 clearNode(traceBox);
  1339.         }
  1340.     },
  1341.  
  1342.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  1343.  
  1344.     copyError: function(error)
  1345.     {
  1346.         var message = [
  1347.             this.getMessage(error.message),
  1348.             error.href,
  1349.             "Line " +  error.lineNo
  1350.         ];
  1351.         copyToClipboard(message.join("\n"));
  1352.     },
  1353.  
  1354.     breakOnThisError: function(error)
  1355.     {
  1356.         if (this.hasErrorBreak(error))
  1357.             Firebug.Debugger.clearErrorBreakpoint(error.href, error.lineNo);
  1358.         else
  1359.             Firebug.Debugger.setErrorBreakpoint(error.href, error.lineNo);
  1360.     },
  1361.  
  1362.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  1363.  
  1364.     className: "errorMessage",
  1365.     inspectable: false,
  1366.  
  1367.     supportsObject: function(object)
  1368.     {
  1369.         return object instanceof ErrorMessage;
  1370.     },
  1371.  
  1372.     inspectObject: function(error, context)
  1373.     {
  1374.         var sourceLink = this.getSourceLink(error);
  1375.         FirebugReps.SourceLink.inspectObject(sourceLink, context);
  1376.     },
  1377.  
  1378.     getContextMenuItems: function(error, target, context)
  1379.     {
  1380.         var breakOnThisError = this.hasErrorBreak(error);
  1381.  
  1382.         var items = [
  1383.             {label: "CopyError", command: bindFixed(this.copyError, this, error) }
  1384.         ];
  1385.  
  1386.         if (error.category == "css")
  1387.         {
  1388.             items.push(
  1389.                 "-",
  1390.                 {label: "BreakOnThisError", type: "checkbox", checked: breakOnThisError,
  1391.                  command: bindFixed(this.breakOnThisError, this, error) },
  1392.  
  1393.                 optionMenu("BreakOnAllErrors", "breakOnErrors")
  1394.             );
  1395.         }
  1396.  
  1397.         return items;
  1398.     }
  1399. });
  1400.  
  1401. // ************************************************************************************************
  1402.  
  1403. this.Assert = domplate(Firebug.Rep,
  1404. {
  1405.     tag:
  1406.         DIV(
  1407.             DIV({class: "errorTitle"}),
  1408.             DIV({class: "assertDescription"})
  1409.         ),
  1410.  
  1411.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  1412.  
  1413.     className: "assert",
  1414.  
  1415.     inspectObject: function(error, context)
  1416.     {
  1417.         var sourceLink = this.getSourceLink(error);
  1418.         context.chrome.select(sourceLink);
  1419.     },
  1420.  
  1421.     getContextMenuItems: function(error, target, context)
  1422.     {
  1423.         var breakOnThisError = this.hasErrorBreak(error);
  1424.  
  1425.         return [
  1426.             {label: "CopyError", command: bindFixed(this.copyError, this, error) },
  1427.             "-",
  1428.             {label: "BreakOnThisError", type: "checkbox", checked: breakOnThisError,
  1429.              command: bindFixed(this.breakOnThisError, this, error) },
  1430.             {label: "BreakOnAllErrors", type: "checkbox", checked: Firebug.breakOnErrors,
  1431.              command: bindFixed(this.breakOnAllErrors, this, error) }
  1432.         ];
  1433.     }
  1434. });
  1435.  
  1436. // ************************************************************************************************
  1437.  
  1438. this.SourceText = domplate(Firebug.Rep,
  1439. {
  1440.     tag:
  1441.         DIV(
  1442.             FOR("line", "$object|lineIterator",
  1443.                 DIV({class: "sourceRow"},
  1444.                     SPAN({class: "sourceLine"}, "$line.lineNo"),
  1445.                     SPAN({class: "sourceRowText"}, "$line.text")
  1446.                 )
  1447.             )
  1448.         ),
  1449.  
  1450.     lineIterator: function(sourceText)
  1451.     {
  1452.         var maxLineNoChars = (sourceText.lines.length + "").length;
  1453.         var list = [];
  1454.  
  1455.         for (var i = 0; i < sourceText.lines.length; ++i)
  1456.         {
  1457.             // Make sure all line numbers are the same width (with a fixed-width font)
  1458.             var lineNo = (i+1) + "";
  1459.             while (lineNo.length < maxLineNoChars)
  1460.                 lineNo = " " + lineNo;
  1461.  
  1462.             list.push({lineNo: lineNo, text: sourceText.lines[i]});
  1463.         }
  1464.  
  1465.         return list;
  1466.     },
  1467.  
  1468.     getHTML: function(sourceText)
  1469.     {
  1470.         return getSourceLineRange(sourceText, 1, sourceText.lines.length);
  1471.     }
  1472. });
  1473.  
  1474. // ************************************************************************************************
  1475. this.ApplicationCache = domplate(Firebug.Rep,
  1476. {
  1477.  
  1478.  
  1479.     tag:OBJECTBOX({onclick: "$showApplicationCache"},
  1480.             OBJECTLINK("$object|summarizeCache")
  1481.         ),
  1482.  
  1483.     summarizeCache: function(applicationCache)
  1484.     {
  1485.         try
  1486.         {
  1487.             return applicationCache.length + " items in offline cache";
  1488.         }
  1489.         catch(exc)
  1490.         {
  1491.             return "https://bugzilla.mozilla.org/show_bug.cgi?id=422264";
  1492.         }
  1493.     },
  1494.  
  1495.     showApplicationCache: function(event)
  1496.     {
  1497.         openNewTab("https://bugzilla.mozilla.org/show_bug.cgi?id=422264");
  1498.     },
  1499.  
  1500.     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  1501.  
  1502.     className: "applicationCache",
  1503.  
  1504.     supportsObject: function(object, type)
  1505.     {
  1506.         if (Ci.nsIDOMOfflineResourceList)
  1507.             return (object instanceof Ci.nsIDOMOfflineResourceList);
  1508.     }
  1509.  
  1510. });
  1511.  
  1512.  
  1513. // ************************************************************************************************
  1514. Firebug.registerRep(
  1515.     this.Undefined,
  1516.     this.Null,
  1517.     this.Number,
  1518.     this.String,
  1519.     this.Func,
  1520.     this.Window,
  1521.     this.ApplicationCache, // must come before Arr (array) else exceptions.
  1522.     this.ErrorMessage,
  1523.     this.Element,
  1524.     this.TextNode,
  1525.     this.Document,
  1526.     this.StyleSheet,
  1527.     this.Event,
  1528.     this.SourceLink,
  1529.     this.SourceFile,
  1530.     this.StackTrace,
  1531.     this.StackFrame,
  1532.     this.jsdStackFrame,
  1533.     this.jsdScript,
  1534.     this.NetFile,
  1535.     this.Property,
  1536.     this.Except,
  1537.     this.Arr
  1538. );
  1539.  
  1540. Firebug.setDefaultRep(this.Obj);
  1541.  
  1542. }});
  1543.  
  1544. // ************************************************************************************************
  1545. /*
  1546.  * The following is http://developer.yahoo.com/yui/license.txt and applies to only code labeled "Yahoo BSD Source"
  1547.  * in only this file reps.js.  John J. Barton June 2007.
  1548.  *
  1549. Software License Agreement (BSD License)
  1550.  
  1551. Copyright (c) 2006, Yahoo! Inc.
  1552. All rights reserved.
  1553.  
  1554. Redistribution and use of this software in source and binary forms, with or without modification, are
  1555. permitted provided that the following conditions are met:
  1556.  
  1557. * Redistributions of source code must retain the above
  1558.   copyright notice, this list of conditions and the
  1559.   following disclaimer.
  1560.  
  1561. * Redistributions in binary form must reproduce the above
  1562.   copyright notice, this list of conditions and the
  1563.   following disclaimer in the documentation and/or other
  1564.   materials provided with the distribution.
  1565.  
  1566. * Neither the name of Yahoo! Inc. nor the names of its
  1567.   contributors may be used to endorse or promote products
  1568.   derived from this software without specific prior
  1569.   written permission of Yahoo! Inc.
  1570.  
  1571. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
  1572. WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  1573. PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  1574. ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  1575. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  1576. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  1577. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  1578. ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1579.  * /
  1580.  */
  1581.